<?php if(!IS_AJAX){?>
<include file="Public:header" />

<style>
    .sourceInput{ max-width:60px; margin-bottom:5px;}
    .sourcePanel{text-align: center;position: absolute;top: 30px;background: #fafafa;border: 1px solid #ddd;padding: 5px; display:none; z-index:3; min-width:110px;}
    .missionform {box-shadow: 0;}
    .formBox{ min-height:160px;}
    .checkoutform .form-inline{ position:relative; padding-left:10px;}
    .checkoutform .checkbox-inline{ padding-top:9px;}
    .checkoutform .form-inline .groupName{ min-width:80px; border-right:1px dotted; padding-right:5px;}
    .checkoutform .form-inline:nth-child(2n){ background-color:rgba(255,255,255,1);border:1px solid #DDDDDD;}
    .checkoutform .form-inline:nth-child(2n-1){ background-color:rgba(0,0,0,0.02);}
    .checkoutform .cover{ width:100%; height:100%; display:none; background:rgba(0,0,0,0.2); position:absolute; top:0; left:0;}
    .checkoutform .sourceEdit{outline: 1px dashed;outline-offset: -6px; transition:all 0.2s ease-in-out;}
    .checkoutform .sourceEdit:hover{ background:rgba(0,0,0,0.03); outline-style:dotted;}
    .groupName{border-right:none!important;}
	 
	.table tbody tr td{vertical-align: middle;}
	.sort{display:inline-block;height:20px;width:20px;vertical-align: middle;}
 
    .directory-info-row .social-links li span{
        background: #EFF0F4;width:25px;height:25px;line-height:25px;text-align:center;display:inline-block;border-radius:50%;
        -webkit-border-radius: 50%;color: #7A7676;cursor:pointer;
    }
    /*.clearp{margin:0;padding:0;}*/
    .pass-span{display:inline-block;text-align:right;width:100%;line-height:40px;}
    .integral-num{display:inline-block; width:50px;height:24px;padding:6px;}
    .table-bordered>thead>tr>th{border-bottom:none;background: linear-gradient(to bottom,#fdfdfd 30%,#e9e9e9);}
    .formBox.a{background:url(__PUBLIC__/a.png) no-repeat center center; background-size:50% auto;}
	.formBox.p{background:url(__PUBLIC__/p.png) no-repeat center center; background-size:50% auto;}
	
    .social-links li span:hover{background-color:#65cea7; color:#fff;}

	.selectlist{margin:0; padding:0;}
	.selectlist ul{padding:0}
	.selectlist li{list-style-type:none; margin:0; padding:0;padding:5px; border-bottom:1px solid #eee; margin:0 8px;}
	.selectlist li:hover{background:#eee;}
	
	.social-links li span:active{ background:#7A7676; color:#fff;}
    @media screen and (max-width: 1100px) {
        .divfloat {
            	text-align: left!important;
        }
        .schedulescroll{
            height:auto!important;
            max-height: 210px;
        }
    }
	.text-orange{color:#f60;}
	
	.a{ cursor:pointer;}
	.limit_h{ height:36px; overflow:hidden; margin-top:6px;}
	/*审批列表*/
	.panel-none{ background-color:#fff; box-shadow:0 1px 4px rgba(0,0,0,0.14); line-height:40px;}
	.panel-list{ border:2px solid transparent; transition:border ease-in-out 0.2s;}
	.panel-list:hover,.panel-list.hover{ border-color:#47b3ff;}
	.panel-list .status{ display:inline-block; padding:5px; border:1px solid #eee; margin-right:5px; margin-bottom:5px;}
	.box-avatar{ padding-left:70px; position:relative;}
	.dir-info .dir-like{ margin-top:12px; color:inherit;}
	.box-detail .text-muted{white-space: nowrap;text-overflow: ellipsis;overflow: hidden;}
	.avatar{ position:absolute; left:10px; top:0;}
	.pagesBox{ height:inherit;}
	.pagesBox > div,.pagesBox > nav{ padding-top:10px; padding-bottom:10px;}
	.pagination{ margin:0;}
	/*审批详细面板*/
	.panel-detail{width: 40%;height: 100%;position: fixed; left:100%;z-index: 4; bottom:0; padding-top:120px;display:none;}
	.panel-detail .panel-footer{ position:absolute;}
	.panel-detail .detail-footer{position: absolute;bottom: 52px;left: 0; background:white; padding-top:10px; padding-bottom:10px;}
	.panel-detail .btn-sm{ width:25%; margin:0 10px;}
	.panel-detail hr{ margin-top:10px; margin-bottom:10px;}
	.panel-detail .info>p{ display:table;}
	.panel-detail .info>p>:first-child{ display:table-cell; min-width:70px;}
	.panel-extended .row{ line-height:34px; white-space:nowrap;}
	.detail-main{background: #fff; box-shadow: 0 10px 23px 2px rgba(0,0,0,.2), 0 3px 6px rgba(0,0,0,.15); height:100%;}
	.cover{position:fixed; left:0; top:0; width:100%; height:100%; display:none; z-index:3}
	/*审批详细的审核列表*/
	.block-list>div{ padding-left:5px; padding-right:5px;}
	.divfloat span{ font-size:12px;}
	.lineHeig_20{line-height: 20px;}
</style>
    <div class="row" style="margin-top:-15px">
        <div class="panel affixelement" style="z-index:3;"  afftop="0" >
            <div class="panel-body">
                <div class="icheck">
                    <form action="<?php echo U('index');?>" id="newajaxlistboxform" style="background:#fff; ">
                        <input type="hidden" name="state" value="1">
                        <input type="hidden" name="type" value="0">
                        <input type="hidden" name="sorttype" value="">
                        <div class="pull-left" style="line-height:34px;padding-top:5px" id="missioncountbox">
                            <div>
                                <span></span><strong><a href="javascript:void(0);" onClick="setstate(1);">未审核（0）</a></strong>　<span class="text-info"><strong><a class="text-info" href="javascript:void(0);" onClick="setstate(2);">审核中（0）</a></strong></span>　<span class="text-success"><strong><a href="javascript:void(0);" onClick="setstate(3);" class="text-success">已通过（0）</a></strong></span>　<span class="text-danger"><strong><a class="text-danger" onClick="setstate(0);" href="javascript:void(0);">已驳回（0）</a></strong></span>　<strong><a href="javascript:void(0);" onClick="setstate('all');">全部（0）</a></strong></div>
                        </div>
                        <div class="btn-group" style="padding-top:5px;">
                            <button data-toggle="dropdown" class="btn btn-default dropdown-toggle" type="button">
                                <span class="dropdown-text">选择时间 </span><span class="caret"></span>
                            </button>
                            <ul role="menu" class="dropdown-menu">
                                <li style="white-space:nowrap" class="row">
                                    <div class="col-xs-12 text-center dropdown-form">
                                        <input class="form-control datepicker" id="starttime" name="starttime" readonly style="cursor:pointer; width:120px; display:inline;height:35px" value="<?php echo $sttime; ?>" placeholder="起始时间" type="text">
                                        至
                                        <input class="form-control datepicker" id="endtime" name="endtime" readonly style="cursor:pointer; width:120px; display:inline;" value="<?php echo $edtime; ?>" placeholder="结束时间" type="text">
                                        <i class="fa icon-times text-danger a f-clearDate btn btn-link" style="display:none;"></i>
                                    </div>                                        
                                </li>
                            </ul>
                        </div>
                        <div class="input-group" style="width:200px;padding-top:5px">
                            <input type="text" name="keywords" value="<?php echo $keywords; ?>"  placeholder="审批名称或姓名" class="form-control" style="height:35px">
                            <span class="input-group-btn">
                                <button type="submit" class="btn btn-default" style="height:35px"><i class="fa icon-search"></i></button>
                            </span>
                        </div>
                        <html:dropdownselect class="typeselect" selected="" name="type" style="height:30.99px; width:120px;margin-top:5px" multi="0" action="{:U('Team/form')}" title="选择审批分类"  placeholder="选择审批分类"  listloaded="listloaded" />
                        <div id="reselectlayout" style="top:0; display:none; left:0; bottom:0; right:0; position:fixed; z-index:4999;"></div>
                        <div id="ajaxlistboxboc" style="display:none;"> 
                            <a href="##" class="btn btn-info" id="ajaxlistboxsa"> 全选 </a> 
                            <a href="##" class="btn btn-info" id="ajaxlistboxca"> 全不选 </a> 
                            <a href="##" class="btn btn-info" id="ajaxlistboxsar"> 反选 </a> 
                            <a rel="{:U('pass')}" href="##" class="btn btn-success"> 通过 </a> 
                        </div>
                        <!-- 右边 -->
                        <!--<div class="btn-group pull-right" style="padding-top:5px;">
                            <button data-toggle="dropdown" class="btn btn-default dropdown-toggle" type="button"><i class="fa icon-list "></i> <span class="caret"></span></button>
                            <ul id="listcheck" role="menu" class="dropdown-menu">
                                <li>
                                    <a onclick="location.href='{:U('index',['type'=>'0'])}'" href="javascript:void(0);"><i class="fa icon-list "></i> 列表视图</a>
                                </li>
                                <li>
                                    <a onclick="location.href='{:U('index',['type'=>'1'])}'" href="javascript:void(0);"><i class="fa icon-th"></i> 表格视图</a>
                                </li>
                            </ul>
                        </div>-->
                        <!-- 右边结束 -->
                        <div style="float:none; clear:both;"></div>
                    </form>
                </div>
            </div>
            <form id="missioncountboxform" data-action="{:U('missioncount')}" action="{:U('missioncount')}"></form>
        </div>
        <div class="col-sm-12 box-detail">
            <div id="masonrybox1"></div>
            <div id="newajaxlistbox" >
                <?php    }?>
                <!-- 数据主体 -->
                <?php if(IS_AJAX){?>
                <volist name="list" id="vo" key="i">
                	<!--审批列表-->
                    <div id="obj-{$vo.id}" onClick="showmore({$vo.id})" class="panel panel-list">
                        <div class="panel-body">
                            <div class="row">
                                <div class="dir-info">
                                    <div class="col-xs-5">
                                    	<!--<div class="avatar">
                                            <img src="/Public/timg.jpg" alt="">
                                        </div>-->
                                        <h5>
                                        	{$vo.proposername}—{$vo.title} 
                                            <?php if(!empty($vo['formcategory_name'])){ ?><span class="text-muted">（{$vo.formcategory_name}）</span><?php } ?>
                                        </h5>
                                        <div class="text-muted"><small>
                                        	<?php echo empty($vo['formtemplateText'])?'暂无内容':str_replace('rn','',$vo['formtemplateText']) ?>
                                        </small></div>
                                    </div>
                                    <div class="col-xs-2 text-success">
                                        <div class="dir-like">
                                        	 <volist name="vo['integral']" id="rvo">
                                                <volist name="rvo['integral']" id="ivo">
                                                    <b>{$InteTypeList[$key]} </b><span class="text-orange"> {$ivo} </span>
                                                </volist>
                                            </volist>
                                        </div>
                                    </div>
                                    <div class="col-xs-3">
                                        <div class="scheStatus-{$vo.id} limit_h"></div>
                                    </div>
                                    <div class="col-xs-2 text-danger">
                                        <div class="dir-like pull-left" style="color:#999;">
                                            {$vo.createtime|date='Y-m-d',###}
                                        </div>
                                        <div class="dir-like obj-status pull-right">
                                        	<switch name="vo.state" >
                                                <case value="0"><span style="color:#D9534F;">已驳回</span></case>
                                                <case value="1">待审核</case>
                                                <case value="2">处理中</case>
                                                <case value="3"><span style="color:#6BC5A4;">已通过</span></case>
                                                <default />待递交
                                            </switch>
                                        </div>
                                        <div class="clearfix"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--审批详细面板-->
                    <div class="panel-detail" id="detail-{$vo.id}">
                    	<div class="detail-main">
                            <div class="panel-heading">{$vo.title}<a onClick="showmore();" href="javascript:;" class=" pull-right text-success"><i class="fa icon-times"></i></a></div>
                            <div class="panel-body">
                                <div class="info">
                                	
                                    <p class="col-xs-6 pull-right">
                                    	<span style="display:inline;">审批状态：</span>
                                        <span>
                                            <switch name="vo.state" >
                                                <case value="0"><span style="color:#D9534F;">已驳回</span></case>
                                                <case value="1">待审核</case>
                                                <case value="2">处理中</case>
                                                <case value="3"><span style="color:#6BC5A4;">已通过</span></case>
                                                <default />待递交
                                            </switch>
                                        </span>
                                    </p>
                                    <p>
                                    	<span>申请人：</span>
                                        <span>{$vo.proposername}</span>
                                    </p>
                                    <p>
                                    	<span>申请时间：</span>
                                        <span>{$vo.createtime|date='Y-m-d H:i',###}</span>
                                    </p>
                                    <p class="text-table" style="max-height: 300px;overflow: hidden;">
                                        <span>内容：</span>
                                        <?php $missionContent=empty($vo['formtemplateText'])?'暂无内容':replacebr($vo['formtemplateText']); ?>
                                        <span class="text-muted" title="{$missionContent}" style="white-space: normal;"><span style="max-height:200px; display:block;" >{$missionContent}</span></span>
                                    </p>
                                    <?php if(!empty($vo['integral'])){ ?> 
                                    <p>
                                    	<span>积分：</span> 
                                        <span>
                                            <volist name="vo['integral']" id="rvo">
                                                <volist name="rvo['integral']" id="ivo">
                                                    <span>{$InteTypeList[$key]}</span><b class="text-orange"> {$ivo} </b>&nbsp;&nbsp;&nbsp;&nbsp;
                                                </volist>
                                            </volist>
                                        </span>
                                    </p>
                                    <?php } ?>
                                    <div>
                                        <hr/>
                                        <span>审批人： </span> 
                                        <span> {$vo.approvername}</span>
                                        <hr/>
                                    </div>
                                </div>
                                <?php 
                                	//审批记录样式配置
                                    $vo['approvername']=str_replace('，',',',$vo['approvername']);
                                	$arrApprover=array_flip(explode(',',$vo['approvername']));
                                	$faIcon=['<i class="fa icon-times text-danger"></i>','<i class="fa icon-check text-success"></i>','<i class="fa icon-ban text-warning"></i>']; 
                                ?>
                                <div class="row mission">
                                    <div class="schedulebox col-lg-12 col-sm-12 schedulescroll" id="schedulebox-{$vo.id}" style="padding:0;padding-bottom:5px;margin-bottom:10px;display:inline-block;height:220px;background-color:#fff;overflow-x:hidden;overflow-y:auto;">
                                    <notempty name="vo['schedule']">
                                        <volist name="vo['schedule']" id="s" key="y">
                                            <div >
                                                <div class="block-list">
                                                	<div class="col-sm-2">{$s.membername}</div>
                                                    <div class="col-sm-2 divfloat text-muted">
                                                        <gt name="s['sendParent']" value="0">
                                                            <?php 	$memberDB=M('Member');
                                                                    if($s['parent_id']>0){
                                                                        $parent_id=$s['parent_id'];
                                                                    }else{
                                                                        $parent_id=$memberDB->where(['id'=>$s['member_id']])->getField('pid');
                                                                    }
                                                                    $parent_name=$memberDB->where(['id'=>$parent_id])->getField('name');
                                                             ?>
                                                            <span title="{$parent_name}">已递交上级({$parent_name})</span>
                                                        </gt>
                                                        <eq name="s['status']" value="0"><span style="color:#d9534f">已驳回</span></eq>
                                                        <eq name="s['status']" value="1"><span style="color:#3c763d;">已通过</span></eq>
                                                    </div>
                                                    <div class="col-sm-3">
                                                        <div class="clearp text-muted" title="{$s.comment}"><notempty name="s['comment']">{$s.comment}<else/>无意见</notempty></div>
                                                    </div>
                                                    <div class="col-sm-3 divfloat text-muted">
                                                        <span class="clearp">
                                                        <notempty name="s.integrals">
                                                            <volist name="s['integrals']" id="rvo">
                                                                {$InteTypeList[$rvo['type']]} : 
                                                                <b class="text-orange">{$rvo.num}</b>分　
                                                            </volist>
                                                        </notempty>
                                                        	<span class="hidden">
                                                            	<gt name="s['ticketnum']" value="0">奖票:<span class="text-orange">{$s.ticketnum}</span></gt>
                                                            </span>
                                                        </span>
                                                    </div>
                                                    <div class="col-sm-2 text-muted divfloat">
                                                        <span class="clearp">{:date('Y-m-d', $s['datatime'])}</span>
                                                    </div>
                                                    <div class="clearfix"></div>
                                                    <script>
                                                        <?php  unset($arrApprover[$s['membername']]); ?>
                                                        $(".scheStatus-{$vo.id}").append('<div class="status" title="{$s.membername}">{$faIcon[$s['status']]} {$s.membername}</div>');
                                                    </script>
                                                </div>
                                            </div>
                                            
                                        </volist>
                                        
                                        <else/>
                                        <div style="padding:5px; text-align:center;padding-bottom:10px;"> 暂无审批记录 </div>
                                    </notempty>
                                    </div>
                                    <div class="col-lg-12 col-sm-12 tableright detail-footer">
                                        <div class="panel-extended">
                                            <div id="schedulebox-{$vo.id}pages"> </div>
                                            <div id="passform-{$vo.id}-integral" >
                                                	
                                                <if condition="$vo['integral']">
                                                	<hr/>
                                                    <volist name="vo['integral']" id="rvo">
                                                        <assign name="midk" value="$key" />
                                                        <div class="form-group row form-inte">
                                                        
                                                            <div class="col-xs-2 ">
                                                                <div class="icheck">
                                                                    <div class="square-red single-row lineHeig_20">
                                                                        <input type="checkbox" checked name="ticket" value="1"/>
                                                                        <label for="ticket" class="label-block">奖票</label>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <volist name="rvo['integral']" id="ivo">
                                                                <input class="form-control" type="hidden" name="integralmember_id[]" value="{$midk}">
                                                                
                                                                <if condition="$giveintegral">
                                                                    <div class="col-xs-1">{$InteTypeList[$key]}:</div>
                                                                    <div class="col-xs-3">
                                                                        <input class="form-control" type="number" name="integralnum[]" value="{$ivo}">
                                                                    </div>
                                                                    <else/>
                                                                    <div class="col-xs-4">
                                                                        {$InteTypeList[$key]}:
                                                                        <span class="text-orange">{$ivo}</span>
                                                                        <input class="form-control" type="hidden" name="integralnum[]" value="{$ivo}">
                                                                    </div>
                                                                </if>
                                                                <input class="form-control" type="hidden" name="integraltype[]" value="{$key}">
                                                            </volist>
                                                        </div>
                                                    </volist> 
                                                </if>
                                            </div>
                                            <form id="schedulebox-{$vo.id}form" action="{:U('schedule', array('id' => $vo['id'],'check'=>'1'))}"></form>
                                            <!--添加界面引导 BY zmx-->
                                            <form id="passform-{$vo.id}" action="{:U('pass')}">
                                                <div class="passform-{$vo.id}">
                                                    <div id="passform-{$vo.id}-integralbox" class="hidden"></div>
                                                    <textarea form="passform-{$vo.id}" class="form-control" name="comment" rows="2" placeholder="填写意见">{$vo.myschedule.comment}</textarea>
                                                    <input form="passform-{$vo.id}" type="hidden" value="0" name="status">
                                                    <input form="passform-{$vo.id}" type="hidden" name="mission_id" value="{$vo['id']}">
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                    <div class="clearfix"></div>
                                </div>
                                
                            </div>
                            <footer class="panel-footer text-center">
                                <gt name="memberInfo['pid']" value="0">
                                    <button onClick="passform{$vo.id}(2);" class="btn btn-info btn-sm"> 递交上级 </button>
                                </gt>
                                <button onclick="passform{$vo.id}(1);" class="btn btn-post btn-sm"> 通过 </button>                                                
                                <button onclick="passform{$vo.id}(0);" class="btn btn-danger btn-sm"> 驳回 </button>
                            </footer>
                        </div>
                    </div>
                    <script>
						//$('.schedulescroll').niceScroll({styler:"fb",cursorcolor:"#65cea7", cursorwidth: '3', cursorborderradius: '0px', background: '#424f63', spacebarenabled:false, cursorborder: '0'});
						//给审批列添加没有审批的人的标签提醒
						<?php  foreach($arrApprover as $k=>$v){ 
							if(trim($k)==''){ continue; } ?>
							$(".scheStatus-{$vo.id}").append('<div class="status" title="{$k}">{$faIcon[2]} {$k}</div>');
						<?php } ?>
						//通过审批的方法
						function passform{$vo.id}(status){
							var data;
							var statusObj=$('#obj-{$vo.id} .obj-status');
							var statusHtml=statusObj.html();
							var sendinput = '<input type="hidden" name="send" value="1">';
							var $obj=$('#passform-{$vo.id}');
							//递交上级
							$obj.find('input[name="send"]').remove();
							if(status == 2){
								status = 1;
								$obj.append(sendinput);
							}
							//动画效果
							statusObj.html('<div class="lockwindowlayout" style="overflow:hidden; height:0; padding:10px 0;"><div class="loader-inner line-scale" style="text-align:center;"><div></div><div></div><div></div><div></div><div></div></div><style>.lockwindowlayout .line-scale{height:20px;}.lockwindowlayout .line-scale div{background:#5ec8ff; height:20px;}</style></div>');
							$obj.find('input[name="status"]').val(status);
							$('#passform-{$vo.id}-integral').find('input[type="number"]').each(function(index, element) {
								$(this).attr('value', $(this).val());
							});
							
							$obj.append($('#passform-{$vo.id}-integral').html());
							
							data = $obj.serialize();
							$.ajax({
								url:$obj.attr('action'),
								data:data,
								type:'POST',
								dataType:"json",
								success: function(ret){
									if(ret.status==0){
										statusObj.html(statusHtml);
										
										if(confirm('已超出当前可以分配的积分权限，是否递交到上级')){ passform{$vo.id}(2) }else{ return false;}
										//$.ThinkBox.error('通过错误，请重试。',{'delayClose':1000,modal:false, 'close': '关闭',x:0,y:0,center:false,locate:['left','top'], show:['',0]});
									}
									if(ret.status == 1){
										//成功了
										if(!$('#schedulebox-{$vo.id}').hasClass('bool')){
											$('#schedulebox-{$vo.id}').ajaxlist();
											$('#schedulebox-{$vo.id}').addClass('bool');
										}else{
											$('#schedulebox-{$vo.id}form').submit();
										}
										setTimeout(function(){
											//更新单个记录，这样不会造成页面有大变化
											$.get("{:U('getOne')}", {
												id:{$vo.id},check:1
											}, function(data){
											}, 'json');
											//updatemasonry();
											if(ret.state=='0'){
												statusObj.html('<span style="color:#D9534F;">已驳回</span>');
											}else if(ret.state=='2'){
												statusObj.html('处理中');
											}else if(ret.state=='3'){
												statusObj.html('<span style="color:#6BC5A4;">已通过</span>');
											}
										},30);
									}
									//如果没有表格则弹窗
									if(ret.status == 2){
										_openWindow('{:U('choiceForm') }&'+data, 500, '选择表格', '确认', function(){ passform{$vo.id}(status);return true;}, '');
										statusObj.html(statusHtml);
									}
									//返回默认状态
									showmore();
								}
							});
							$obj.find('.form-inte').remove();
							$obj.find('hr').remove();
						}
					</script>
                </volist>
                <!--<div onClick="showmore();" class="cover"></div>-->
            	<!-- 数据主体结束 -->
                <?php } ?>
                <?php if(!IS_AJAX){?>
            </div>
	        <div id="newajaxlistboxpages" class="pagesBox text-center panel"> <?php echo $pages;?> </div>
        </div>
    </div>
<include file="Public:script" />
<script src="__PUBLIC__/Js/jquery.masonry.min.js"></script>
<script>
	//显示/隐藏面板
    //$('#missioncountbox').ajaxlist();
	//重写一个异步提交的方法，数据来自另一个表单
	$('#missioncountboxform').submit(function(e) {
        e.preventDefault();
		var $aim=$('#'+$(this).attr('id').replace('form',''));
		var $obj=$('#newajaxlistboxform');
		$.getJSON($(this).attr('action'),$obj.serialize(),function(data){
			if(data.tbody){
				$aim.html(data.tbody);	
			}
		});
		return;
    });
    $('#newajaxlistbox').ajaxlist({success:function(){
		showmore();
		//$("#missioncountboxform").submit();

        //当数据成功获取的时候将表单转化为纯文

        /*$('.formBox .form-control ').each(function(index, element) {
            var hidden = $('.hidden').val();
            $('.hidden').replaceWith('');
            var val = $(this).val();
            $(this).replaceWith('<span style="color:#f60;">'+val+'</span>');
        });
        //当数据成功获取的时候将选择项转化为纯文本
        $('.formBox .single-row').each(function(index, element) {
            $(this).find('*').unbind();
            if($(this).find(".checked").length==0){
                $(this).parent().remove();
            }else{
                var input=$(this).find(".checked").removeAttr("class").parent().next();
                if(isNaN(Number(input.val()))){
                    //input.attr("type","number").addClass('form-control').css('max-width','110px');
                }
            }
            //显示出可点击的框框
            if($(this).find('.sourcePanel').length){
                $(this).parent().addClass('sourceEdit');
            }
        });
        $('.formBox form').each(function(){
            var table=$(this).html();
            table=table.replace(/<[^>]+>/g,"");
            $(this).replaceWith(table);
        });
        $('.hiddenform form.checkoutform .form-control ').each(function(index, element) {
            var val = $(this).val();
            $(this).replaceWith('<span style="color:#f60;">'+val+'</span><br/>');
        });
        $(".hiddenform form.checkoutform:has('table')").each(function() {
            var tab=$(this).children('table').children('tbody').html();
            tab=tab.replace('tr',"div");
            tab=tab.replace('td',"div");
            $(this).replaceWith(tab);
        });*/
        $('.missiontable thead th').each(function(){
            $(this).attr('click','0');
            if($.session.get('myth_'+$(this).index())){
                $(this).attr('click', $.session.get('myth_'+$(this).index()));
            }
            $.session.set('myth_'+$(this).index(),'0');//先清零,防止页面出问题
            if($(this).index()>3 && $(this).index()<6){
                $(this).children('i').addClass('icon-unsorted');
                if($(this).attr('click')=='0'){
                    $(this).children('i').removeAttr('class').addClass('fa icon-unsorted');
                }else if($(this).attr('click')=='1'){
                    $(this).children('i').removeAttr('class').addClass('fa icon-sort-down');
                }else if($(this).attr('click')=='2'){
                    $(this).children('i').removeAttr('class').addClass('fa icon-sort-up');
                }
                $(this).click(function(){
                    if($(this).attr('click')=='0'){
                        $('.missiontable thead th').attr('click','0');
                        $(this).attr('click','1');
                        $.session.set('myth_'+$(this).index(),'1');//后赋值
                    }else if($(this).attr('click')=='1'){
                        $('.missiontable thead th').attr('click','0');
                        $(this).attr('click','2');
                        $.session.set('myth_'+$(this).index(),'2');
                    }else if($(this).attr('click')=='2'){
                        $('.missiontable thead th').attr('click','0');
                        $(this).attr('click','1');
                        $.session.set('myth_'+$(this).index(),'1');
                    }
                    $("#newajaxlistboxform input[name='sorttype']").val($(this).index()+'_'+$(this).attr('click'));
                    $('#newajaxlistboxform').submit();
                });
            }
        });
		$("#missioncountboxform").submit();
    }});
	
   
	
	//选择时间的控件点击事件不冒泡
	$(".btn-group .datepicker").click(function(e) {
		event.stopPropagation();
    });
	//选择时间的效果显示到面板中
    $('.icheck input').change(function(){
		//判断时间控件
		if($(this).val()&&$(this).siblings('.datepicker').val()){
			$(".dropdown-text").text($(this).val()+' 至 '+$(this).siblings('.datepicker').val()+' ')
			$(this).parent().click();
			$(".f-clearDate").show();
		}else if($(this).hasClass('datepicker')){
			return;
		}
        $('#newajaxlistboxform').submit();
		
		//$("#missioncountboxform").attr('action',$("#missioncountboxform").attr('data-action')+'&'+$('#newajaxlistboxform').serialize());
		//$("#missioncountboxform").submit();
    });
	//清除时间选择状态
	$(".f-clearDate").click(function(e) {
		$(".dropdown-text").text('选择时间');
		$(".dropdown-menu input").val('');
		$('#newajaxlistboxform').submit();
		//$("#missioncountboxform").submit();
        $(this).hide();
    });
   
	
	
	//审批提交方法
    function mission_send(id,e){
        if(!confirm('确定递交吗？')){
            return false;
        }
        hideLayer();
        $.post('{:U('send')}', {id:id}, function(data){
            if(data.status == 1){
                $('#newajaxlistboxform').submit();
                //updateList();
            }else{
                alert(data.info);
            }
        }, 'json');
    }
    function mission_cancel(id,e){
        if(!confirm('确定取消吗？')){
            return false;
        }
        hideLayer();
        $.post('{:U('cancel')}', {id:id}, function(data){
            if(data.status == 1){
                $('#newajaxlistboxform').submit();
                //updateList();
            }else{
                alert(data.info);
            }
        }, 'json');
    }
    function setstate(state){
        //reloadmasonry();
        $('#newajaxlistboxform').find('input[name="state"]').val(state);
        $('#newajaxlistboxform').submit();
    }
	
	function showmore(id){
		var $obj=$('.panel-detail.show');
		var $box=$(".box-detail");
		if(!$obj.is(":animated")){
			$('div.hover').removeClass('hover');
			if($obj.attr('id')=='detail-'+id||$('#detail-'+id).length==0){
				$box.css('width','100%');
				$obj.css({left:'100%'}).hide().removeClass('show');
			}else{
				$box.css('width','100%');
				$('.panel-detail').css({left:'100%'}).hide().removeClass('show');
				$box.filter(':not(:animated)').css({width:'58%'});
				$('#detail-'+id).filter(':not(:animated)').show().animate({left:'60%'},'fast','swing').addClass('show');
				$(".cover").show();
				$('#obj-'+id).addClass('hover');
			}
		}
	}
    function listloaded(){
        $('.typeselect').blur(function(){
            $("#newajaxlistboxform input[name='formcategory_id']").remove();
            if($('div.typeselect span.itemspan').children("input:eq(1)").length!=0){
                $('#newajaxlistboxform').append("<input type='hidden' name='formcategory_id' value='"+$('.typeselect .itemspan').children("input:eq(1)").attr('value')+"'>");
            }
            $('#missioncountbox').submit();
            //$('#newajaxlistboxform').submit();
        });
    }
	
    /*function reloadmasonry(){
        $('#masonrybox1').masonry('destroy').empty();
        $('#masonrybox1').masonry({
            itemSelector: '.box',
            columnWidth: 0,
            isAnimated : true
        });
    }
    function updatemasonry(){
        if($('#masonrybox1').children().length > 0){
            $('#masonrybox1').masonry('destroy').empty();
        }
        $('#masonrybox1').masonry({
            itemSelector: '.box',
            columnWidth: 0,
            isAnimated : true
        });
    }
    updatemasonry();
    //有关于页面的一系列事件
    function sourceInput(e){
        //$(this).find(".sourceInput").attr("type",'number')
        if($(this).find(".sourceInput").css('display')!='block'){
            $(".sourcePanel").hide();
        }
        $(this).find(".sourcePanel").show();
        $(this).find(".hidden").removeClass("hidden");
    }*/
</script>
</body></html><?php }?>